<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>悦质保</title>
    <link href="../css/Hui.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
        body { background: url(../image/login_bg.jpg) no-repeat left top; background-size: cover; }
    </style>
</head>
<body class="H-height-100-percent H-box-sizing-border-box H-overflow-hidden">
<div class="fix">
    <div class="H-horizontal-center H-padding-vertical-both-25">
        <div class="H-text-align-center">
            <img src="../image/logo.png" class="H-border-radius-12 H-margin-vertical-top-10" style="width:80px;height:80px;" />
<!--            <div class="H-font-size-18">质保通</div>-->
        </div>
    </div>
    <div class="H-border-vertical-top-after H-margin-vertical-top-10">

        <div class="H-padding-15 H-margin-vertical-top-10">
            <button class="H-button H-width-100-percent  H-font-size-15 H-outline-none
                H-padding-vertical-both-15 H-padding-horizontal-both-20 H-theme-background-color9
                H-theme-font-color-white H-theme-border-color9 H-theme-border-color9-click
                H-theme-background-color9-click H-theme-font-color9-click H-border-radius-3" id="merchantloginBtn">我是商家</button>
        </div>


        <div class="H-padding-15 H-margin-vertical-top-10">
            <button class="H-button H-width-100-percent  H-font-size-15 H-outline-none
                H-padding-vertical-both-15 H-padding-horizontal-both-20 H-theme-background-color9
                H-theme-font-color-white H-theme-border-color9 H-theme-border-color9-click
                H-theme-background-color9-click H-theme-font-color9-click H-border-radius-3" id="customerloginBtn">我是客户</button>
        </div>
    </div>




</div>
<div class="H-padding-vertical-bottom-10" style="margin-top: 20rem; font-weight: bold;">

    <div class="H-border-vertical-top-after H-margin-vertical-bottom-10">

        <!-- 操作选择弹窗 -->
        <div class="action-popup" id="actionPopup" style="text-align: center;">
            客服电话：<div class="popup-item call-action" style="text-align: center;color: #1e9fff;display: inline">
                13283356657<i id="phoneNumber"></i>
            </div>
            <div class="popup-item copy-action">
                <i></i>
            </div>
        </div>
        <div class="mask" id="mask"></div>

    </div>


</div>

<div style="text-align: center; font-size: 12px;">
<!--    <a href="http://beian.miit.gov.cn/" target="_blank">冀ICP备2025119836号</a>-->
</div>

<div style="text-align: center; font-size: 12px;">
    <label class="text-neutral-600">
        <a href="/app/agreement" target="_blank" class="link-primary">《用户服务协议》</a> 与
        <a href="/app/agreement" target="_blank" class="link-primary">《隐私政策》</a>
    </label>
</div>


<script src="../script/H.js" type="text/javascript"></script>
<script src="../script/jquery-3.7.1.min.js" type="text/javascript"></script>
<script src="../script/md5.js" type="text/javascript"></script>
<script src="../api.js" type="text/javascript"></script>
<script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
<script src="../miniprogram2h5.js" type="text/javascript"></script>
<script src="https://unpkg.com/vconsole@latest/dist/vconsole.min.js"></script>
<script>
    // VConsole 默认会挂载到 `window.VConsole` 上
    // var vConsole = new window.VConsole();
    // vConsole.hideSwitch(); // 隐藏开关
    // vConsole.hide(); // 确保面板关闭（若已打开）
</script>
<!--<script src="../api.js" type="text/javascript"></script>-->
<script type="text/javascript">

    $('#merchantloginBtn').click(function () {
        window.location.href='/app/merchantlogin';
    });
    $('#customerloginBtn').click(function () {
        window.location.href='/app/customersearch';
    });


    // 核心号码（无分隔符，用于功能调用）
    const phoneNumber = '13283356657';
    const phoneEl = document.getElementById('phoneNumber');
    const popupEl = document.getElementById('actionPopup');
    const maskEl = document.getElementById('mask');
    const callAction = document.querySelector('.call-action');
    const copyAction = document.querySelector('.copy-action');

    // 点击电话号码显示弹窗
    phoneEl.addEventListener('click', function(e) {
        e.stopPropagation(); // 阻止事件冒泡，避免点击弹窗外关闭
        showPopup();
    });

    // 显示弹窗
    function showPopup() {
        popupEl.style.display = 'block';
        maskEl.style.display = 'block';
    }

    // 隐藏弹窗
    function hidePopup() {
        // popupEl.style.display = 'none';
        // maskEl.style.display = 'none';
    }

    // 拨打电话功能
    callAction.addEventListener('click', function() {
        hidePopup();
// 移动端调用拨号功能
        if (/(Android|iPhone|iPad|iPod)/i.test(navigator.userAgent)) {
            location.href = `tel:${phoneNumber}`;
        }
// PC端提示
        else {
            alert('PC端无法直接拨打，请复制号码后手动拨号');
        }
    });

    // 复制号码功能
    copyAction.addEventListener('click', function() {
        hidePopup();
        navigator.clipboard.writeText(phoneNumber).then(() => {
            alert('号码已复制到剪贴板：' + phoneNumber);
        }).catch(() => {
            alert('复制失败，请手动输入：' + phoneNumber);
        });
    });

    // 点击弹窗外或遮罩层关闭弹窗
    maskEl.addEventListener('click', hidePopup);
    document.addEventListener('click', function(e) {
        if (!phoneEl.contains(e.target) && !popupEl.contains(e.target)) {
            hidePopup();
        }
    });



    $(function () {

        var password = localStorage.getItem("password" );
        var username = localStorage.getItem("username");
        debugger

        if(username !== '' && password !== "" && username != null && password != null){
            $.ajax({
                type : "post",
                url : '/app/loginV1',
                contentType:'application/json;charset=utf-8',
                dataType : "json",
                data : JSON.stringify({
                    username: username,
                    password: password
                }),
                async : true,
                success : function(json){
                    if(json.code == 0){
                        var user = json.user;
                        var userId = json.user.userId;
                        debugger
                        localStorage.setItem('password', password);
                        localStorage.setItem("user", user);
                        localStorage.setItem("userId", userId);
                        localStorage.setItem("username", user.username);
                        if(userId === 1){
                            window.location.href='/app/adminindex';
                        }else{
                            window.location.href='/app/merchantindex';
                        }
                    }else{
                        alert(json.msg);
                    }
                },
            });
        }



        // if(userId === '1'){
        //     window.location.href='/app/adminindex';
        // }else{
        //     window.location.href='/app/merchantindex';
        // }


    })


</script>
</body>
</html>